﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Text;
using netDxf;
using netDxf.Blocks;
using netDxf.Collections;
using netDxf.Entities;
using netDxf.Header;
using netDxf.Objects;
using netDxf.Tables;
using netDxf.Units;
using Attribute = netDxf.Entities.Attribute;
using Image = netDxf.Entities.Image;
using Point = netDxf.Entities.Point;
using Trace = netDxf.Entities.Trace;
using System.Threading;

namespace TestDxfDocument
{
    class Burrs
    {
        public static void Burr(Dictionary<string, Object> data)
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中性线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
            //作图
            //参数
            string path = Convert.ToString(data["path"]);
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0)
            {
                if (soal < 67)
                {
                    scale = 4.0;
                }
                else if (soal < 90)
                {
                    scale = 3.0;
                }
                else if (soal < 134)
                {
                    scale = 2.0;
                }
                else if (soal < 178)
                {
                    scale = 1.5;
                }
                else if (soal < 268)
                {
                    scale = 1.0;
                }
                else if (soal < 357)
                {
                    scale = 0.75;
                }
                else
                {
                    scale = 0.5;
                }
            }
            double pi = Math.PI;
            string btc = Convert.ToString(data["btc"]);
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double apmx = Convert.ToDouble(data["apmx"]) * scale;
            double dn = Convert.ToDouble(data["dn"]) * scale;
            double bhta = Convert.ToDouble(data["bhta"]) * pi / 180;
            string ccms = Convert.ToString(data["ccms"]);
            double czc = Convert.ToDouble(data["czc"]);
            double db = Convert.ToDouble(data["db"]) * scale;
            double ds = Convert.ToDouble(data["ds"]) * scale;
            double TG = Convert.ToDouble(data["tg"]);
            if (ccms == "MKG")
            {
                if (czc == 0)
                {
                    db = 9.045 * scale;
                    ds = 6.4 * scale;
                    TG = 0.05205;
                }
                if (czc == 1)
                {
                    db = 12.065 * scale;
                    ds = 9.4 * scale;
                    TG = 0.04988;
                }
                if (czc == 2)
                {
                    db = 17.78 * scale;
                    ds = 14.6 * scale;
                    TG = 0.04995;
                }
                if (czc == 3)
                {
                    db = 23.825 * scale;
                    ds = 19.8 * scale;
                    TG = 0.05020;
                }
                if (czc == 4)
                {
                    db = 31.267 * scale;
                    ds = 25.9 * scale;
                    TG = 0.05194;
                }
                if (czc == 5)
                {
                    db = 44.399 * scale;
                    ds = 37.6 * scale;
                    TG = 0.05263;
                }
                if (czc == 6)
                {
                    db = 63.348 * scale;
                    ds = 53.9 * scale;
                    TG = 0.05214;
                }
            }
            if (ccms == "MEG")
            {
                TG = 0.05;
                if (czc == 4)
                {
                    db = 4 * scale;
                    ds = 2.9 * scale;
                }
                if (czc == 6)
                {
                    db = 6 * scale;
                    ds = 4.4 * scale;
                }
                if (czc == 80)
                {
                    db = 80 * scale;
                    ds = 70.2 * scale;
                }
                if (czc == 100)
                {
                    db = 100 * scale;
                    ds = 88.4 * scale;
                }
                if (czc == 120)
                {
                    db = 120 * scale;
                    ds = 106.6 * scale;
                }
                if (czc == 160)
                {
                    db = 160 * scale;
                    ds = 143 * scale;
                }
                if (czc == 200)
                {
                    db = 200 * scale;
                    ds = 179.4 * scale;
                }
            }
            double isframe = Convert.ToDouble(data["isframe"]);
            double prfa = Convert.ToDouble(data["prfa"]) * pi / 180;
            double re = Convert.ToDouble(data["re"]) * scale;
            double dcx = Convert.ToDouble(data["dcx"]) * scale;
            double prfrad = Convert.ToDouble(data["prfrad"]) * scale;
            double lh = Convert.ToDouble(data["lh"]) * scale;
            double dcn = Convert.ToDouble(data["dcn"]) * scale;
            double pna = Convert.ToDouble(data["pna"]) * pi / 180;
            double dc1 = Convert.ToDouble(data["dc1"]) * scale;
            double dc2 = Convert.ToDouble(data["dc2"]) * scale;
            //坐标
            //主视图
            if (btc == "01")
            {
                if (ccms == "ZYL")
                {
                    Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
                    Vector2 v2 = new Vector2(v1.X + 0.5, -0.5);
                    Vector2 v3 = new Vector2(v2.X, -ls);
                    Vector2 v4 = new Vector2(dn / 2, v3.Y - (dconms - dn) / 2 * Math.Cos(bhta) / Math.Sin(bhta));
                    Vector2 v5 = new Vector2(v4.X, -oal + apmx + (dconms - dn) / 2 * Math.Cos(bhta) / Math.Sin(bhta));
                    Vector2 v6 = new Vector2(dc / 2, -oal + apmx);
                    Vector2 v8 = new Vector2(v6.X, -oal);
                    Vector2 v11 = new Vector2(-v8.X, v8.Y);
                    Vector2 v13 = new Vector2(-v6.X, v6.Y);
                    Vector2 v14 = new Vector2(-v5.X, v5.Y);
                    Vector2 v15 = new Vector2(-v4.X, v4.Y);
                    Vector2 v16 = new Vector2(-v3.X, v3.Y);
                    Vector2 v17 = new Vector2(-v2.X, v2.Y);
                    Vector2 v18 = new Vector2(-v1.X, v1.Y);
                    Vector2 v19 = new Vector2(0, 2);
                    Vector2 v20 = new Vector2(0, -oal - 2);
                    //线段
                    //主视图
                    Vector2[] Line1 = { v1, v2 };
                    fun.drawBLine(dxf, Line1, 0.3, contour);
                    Vector2[] Line2 = { v2, v3 };
                    fun.drawBLine(dxf, Line2, 0.3, contour);
                    Vector2[] Line3 = { v3, v4 };
                    fun.drawBLine(dxf, Line3, 0.3, contour);
                    Vector2[] Line4 = { v4, v5 };
                    fun.drawBLine(dxf, Line4, 0.3, contour);
                    Vector2[] Line5 = { v5, v6 };
                    fun.drawBLine(dxf, Line5, 0.3, contour);
                    Vector2[] Line6 = { v6, v8 };
                    fun.drawBLine(dxf, Line6, 0.5, contour);
                    Vector2[] Line8 = { v8, v11 };
                    fun.drawBLine(dxf, Line8, 0.3, contour);
                    Vector2[] Line11 = { v11, v13 };
                    fun.drawBLine(dxf, Line11, 0.5, contour);
                    Vector2[] Line13 = { v13, v14 };
                    fun.drawBLine(dxf, Line13, 0.3, contour);
                    Vector2[] Line14 = { v14, v15 };
                    fun.drawBLine(dxf, Line14, 0.3, contour);
                    Vector2[] Line15 = { v15, v16 };
                    fun.drawBLine(dxf, Line15, 0.3, contour);
                    Vector2[] Line16 = { v16, v17 };
                    fun.drawBLine(dxf, Line16, 0.3, contour);
                    Vector2[] Line17 = { v17, v18 };
                    fun.drawBLine(dxf, Line17, 0.3, contour);
                    Vector2[] Line18 = { v18, v1 };
                    fun.drawBLine(dxf, Line18, 0.3, contour);
                    Vector2[] Line19 = { v19, v20 };
                    fun.drawPlinetype(dxf, Line19, 0.15,centre, Linetype.Center);
                    Vector2[] Line20 = { v17, v2 };
                    fun.drawBLine(dxf, Line20, 0.3, contour);
                    Vector2[] Line21 = { v16, v3 };
                    fun.drawBLine(dxf, Line21, 0.3, contour);
                    Vector2[] Line22 = { v15, v4 };
                    fun.drawBLine(dxf, Line22, 0.3, contour);
                    Vector2[] Line23 = { v14, v5 };
                    fun.drawBLine(dxf, Line23, 0.3, contour);
                    Vector2[] Line24 = { v13, v6 };
                    fun.drawBLine(dxf, Line24, 0.3, contour);
                    //标注样式
                    //箭头样式
                    DimensionStyle dimensionStyle = fun.CreateDimStyle();
                    dimensionStyle.ArrowSize = 0.2;
                    dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                    dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                    //文本样式
                    dimensionStyle.TextHeight = 1.0;
                    double offset = 10;
                    //线段尺寸标注
                    //尺寸1
                    LinearDimension dim1 = new LinearDimension(new Line(v6, v8), offset + (v3.X + v6.X) / 2 - v6.X, 270, dimensionStyle);
                    dim1.UserText = "APMX = " + Math.Round(apmx / scale, 2);
                    dxf.AddEntity(dim1);
                    //尺寸2
                    LinearDimension dim2 = new LinearDimension(new Line(v11, v8), -offset, 0, dimensionStyle);
                    dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                    dxf.AddEntity(dim2);
                    //尺寸4
                    LinearDimension dim4 = new LinearDimension(new Line(v1, v3), offset + 0.25 + v6.X - (v3.X + v6.X) / 2, 270, dimensionStyle);
                    dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
                    dxf.AddEntity(dim4);
                    //尺寸5
                    if (dconms >= dc)
                    {
                        LinearDimension dim5 = new LinearDimension(new Line(v8, v1), offset * 2 + (v2.X - v8.X) / 2 + 0.25, 270, dimensionStyle);
                        dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                        dxf.AddEntity(dim5);
                    }
                    else
                    {
                        LinearDimension dim5 = new LinearDimension(new Line(v8, v1), offset * 2 + (v8.X - v2.X) / 2 + 0.25, 270, dimensionStyle);
                        dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                        dxf.AddEntity(dim5);
                    }
                    //尺寸6
                    LinearDimension dim6 = new LinearDimension(new Line(v17, v2), offset + 0.5, 0, dimensionStyle);
                    dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
                    dxf.AddEntity(dim6);
                    //尺寸8
                    LinearDimension dim8 = new LinearDimension(new Line(v15, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
                    dim8.UserText = "DN = " + Math.Round(dn / scale, 2);
                    dxf.AddEntity(dim8);
                }
                if (ccms == "MKG" || ccms == "MEG")
                {
                    ls = (db - ds) / TG;
                    //坐标
                    Vector2 v1 = new Vector2(ds / 2 - 0.5, 0);
                    Vector2 v2 = new Vector2(ds / 2 + Math.Sqrt(0.25 / (1 + TG * TG / 4)) * TG / 2, -Math.Sqrt(0.25 / (1 + TG * TG / 4)));
                    Vector2 v3 = new Vector2(db / 2, -ls);
                    Vector2 v4 = new Vector2(dn / 2, v3.Y - v3.X + dn / 2);
                    Vector2 v5 = new Vector2(v4.X, -oal + apmx + (dconms - dn) / 2 * Math.Cos(bhta) / Math.Sin(bhta));
                    Vector2 v6 = new Vector2(dc / 2, -oal + apmx);
                    Vector2 v8 = new Vector2(v6.X, -oal);
                    Vector2 v11 = new Vector2(-v8.X, v8.Y);
                    Vector2 v13 = new Vector2(-v6.X, v6.Y);
                    Vector2 v14 = new Vector2(-v5.X, v5.Y);
                    Vector2 v15 = new Vector2(-v4.X, v4.Y);
                    Vector2 v16 = new Vector2(-v3.X, v3.Y);
                    Vector2 v17 = new Vector2(-v2.X, v2.Y);
                    Vector2 v18 = new Vector2(-v1.X, v1.Y);
                    Vector2 v19 = new Vector2(0, 2);
                    Vector2 v20 = new Vector2(0, -oal - 2);
                    //线段
                    Vector2[] Line1 = { v1, v2 };
                    fun.drawBLine(dxf, Line1, 0.3, contour);
                    Vector2[] Line2 = { v2, v3 };
                    fun.drawBLine(dxf, Line2, 0.3, contour);
                    LwPolyline Arc1 = new LwPolyline();
                    Arc1.Vertexes.Add(new LwPolylineVertex(v3));
                    Arc1.Vertexes.Add(new LwPolylineVertex(v4));
                    Arc1.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                    fun.PolyFill(dxf, Arc1, 0.3, contour);
                    LwPolyline Arc2 = new LwPolyline();
                    Arc2.Vertexes.Add(new LwPolylineVertex(v15));
                    Arc2.Vertexes.Add(new LwPolylineVertex(v16));
                    Arc2.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                    fun.PolyFill(dxf, Arc2, 0.3, contour);
                    Vector2[] Line3 = { v4, v5 };
                    fun.drawBLine(dxf, Line3, 0.3, contour);
                    Vector2[] Line4 = { v5, v6 };
                    fun.drawBLine(dxf, Line4, 0.3, contour);
                    Vector2[] Line5 = { v6, v8 };
                    fun.drawBLine(dxf, Line5, 0.5, contour);
                    Vector2[] Line7 = { v8, v11 };
                    fun.drawBLine(dxf, Line7, 0.3, contour);
                    Vector2[] Line10 = { v11, v13 };
                    fun.drawBLine(dxf, Line10, 0.5, contour);
                    Vector2[] Line12 = { v13, v14 };
                    fun.drawBLine(dxf, Line12, 0.3, contour);
                    Vector2[] Line13 = { v14, v15 };
                    fun.drawBLine(dxf, Line13, 0.3, contour);
                    Vector2[] Line15 = { v16, v17 };
                    fun.drawBLine(dxf, Line15, 0.3, contour);
                    Vector2[] Line16 = { v17, v18 };
                    fun.drawBLine(dxf, Line16, 0.3, contour);
                    Vector2[] Line17 = { v18, v1 };
                    fun.drawBLine(dxf, Line17, 0.3, contour);
                    Vector2[] Line18 = { v17, v2 };
                    fun.drawBLine(dxf, Line18, 0.3, contour);
                    Vector2[] Line19 = { v16, v3 };
                    fun.drawBLine(dxf, Line19, 0.3, contour);
                    Vector2[] Line20 = { v15, v4 };
                    fun.drawBLine(dxf, Line20, 0.3, contour);
                    Vector2[] Line21 = { v14, v5 };
                    fun.drawBLine(dxf, Line21, 0.3, contour);
                    Vector2[] Line22 = { v13, v6 };
                    fun.drawBLine(dxf, Line22, 0.3, contour);
                    Vector2[] Line23 = { v19, v20 };
                    fun.drawPlinetype(dxf, Line23, 0.15, centre, Linetype.Center);
                    //标注样式
                    //箭头样式
                    DimensionStyle dimensionStyle = fun.CreateDimStyle();
                    dimensionStyle.ArrowSize = 0.2;
                    dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                    dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                    //文本样式
                    dimensionStyle.TextHeight = 1.0;
                    double offset = 10;
                    //线段尺寸标注
                    //尺寸1
                    LinearDimension dim1 = new LinearDimension(new Line(v6, v8), offset + (v3.X + v6.X) / 2 - v6.X, 270, dimensionStyle);
                    dim1.UserText = "APMX = " + Math.Round(apmx / scale, 2);
                    dxf.AddEntity(dim1);
                    //尺寸2
                    LinearDimension dim2 = new LinearDimension(new Line(v11, v8), -offset, 0, dimensionStyle);
                    dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                    dxf.AddEntity(dim2);
                    //尺寸5
                    if (dconms >= dc)
                    {
                        LinearDimension dim5 = new LinearDimension(new Line(v8, v1), offset * 2 + (v2.X - v8.X) / 2 + 0.25, 270, dimensionStyle);
                        dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                        dxf.AddEntity(dim5);
                    }
                    else
                    {
                        LinearDimension dim5 = new LinearDimension(new Line(v8, v1), offset * 2 + (v8.X - v2.X) / 2 + 0.25, 270, dimensionStyle);
                        dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                        dxf.AddEntity(dim5);
                    }
                    //尺寸8
                    LinearDimension dim8 = new LinearDimension(new Line(v15, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
                    dim8.UserText = "DN = " + Math.Round(dn / scale, 2);
                    dxf.AddEntity(dim8);
                    //尺寸9
                    RadialDimension dimrad1 = new RadialDimension(new Vector2(offset * 2, offset * 2), new Vector2(0, 0), offset * 2, dimensionStyle);//DimensionStyle.Default);
                    dimrad1.UserText = "CCMS = " + ccms + ",CZC=" + czc;
                    dxf.AddEntity(dimrad1);
                }
                //图框
                if (isframe == 1)
                {
                    Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }
            if (btc == "21")
            {
                double dcx1 = apmx * 2 * Math.Tan(prfa / 2) + dc;
                Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(v1.X + 0.5, -0.5);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(dn / 2, v3.Y - (dconms - dn) / 2 * Math.Cos(45 * pi / 180) / Math.Sin(45 * pi / 180));
                Vector2 v5 = new Vector2(v4.X, -oal + apmx);
                Vector2 v6 = new Vector2(dcx1 / 2, -oal + apmx);
                Vector2 v7 = new Vector2(dc / 2, -oal);
                Vector2 v8 = new Vector2(-v7.X, v7.Y);
                Vector2 v9 = new Vector2(-v6.X, v6.Y);
                Vector2 v10 = new Vector2(-v5.X, v5.Y);
                Vector2 v11 = new Vector2(-v4.X, v4.Y);
                Vector2 v12 = new Vector2(-v3.X, v3.Y);
                Vector2 v13 = new Vector2(-v2.X, v2.Y);
                Vector2 v14 = new Vector2(-v1.X, v1.Y);
                Vector2 v15 = new Vector2(0, 2);
                Vector2 v16 = new Vector2(0, -oal - 2);
                //线段
                //主视图
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v9, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v7 };
                fun.drawBLine(dxf, Line6, 0.5, contour);
                Vector2[] Line7 = { v7, v8 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v8, v9 };
                fun.drawBLine(dxf, Line8, 0.5, contour);
                Vector2[] Line10 = { v10, v11 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v11, v12 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v12, v13 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v13, v14 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line18 = { v14, v1 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v15, v16 };
                fun.drawPlinetype(dxf, Line19, 0.15, centre, Linetype.Center);
                Vector2[] Line20 = { v13, v2 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v12, v3 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v11, v4 };
                fun.drawBLine(dxf, Line22, 0.3, contour);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v7, v8), -offset, 0, dimensionStyle);
                dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v7, v6), offset + (v6.X - v7.X) / 2, 270, dimensionStyle);
                dim3.UserText = "APMX = " + Math.Round(apmx / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v1, v3), offset + 0.25 + v6.X - v3.X, 270, dimensionStyle);
                dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v7, v1), offset * 2 + 0.25 + v6.X - (v3.X + v7.X) / 2, 270, dimensionStyle);
                dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v13, v2), offset + 0.5, 0, dimensionStyle);
                dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                Angular2LineDimension angdim7 = new Angular2LineDimension(new Line(v8, v9), new Line(v7, v6), dc / 2 / Math.Tan(prfa / 2) + apmx / 2, dimensionStyle);
                angdim7.UserText = "PRFA = " + Math.Round(prfa / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim7);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v11, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
                dim8.UserText = "DN = " + Math.Round(dn / scale, 2);
                dxf.AddEntity(dim8);
                //图框
                if (isframe == 1)
                {
                    Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }
            if (btc == "07")
            {
                double dcn1 = dc - apmx / Math.Tan(prfa) * 2;
                Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(v1.X + 0.5, -0.5);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(dn / 2, v3.Y - (dconms - dn) / 2 * Math.Cos(45 * pi / 180) / Math.Sin(45 * pi / 180));
                Vector2 v5 = new Vector2(v4.X, -oal + apmx + (dconms - dn) / 2 * Math.Cos(45 * pi / 180) / Math.Sin(45 * pi / 180));
                Vector2 v6 = new Vector2(v3.X, -oal + apmx);
                Vector2 v7 = new Vector2(dcn1 / 2, v6.Y);
                Vector2 v8 = new Vector2(dc / 2, -oal);
                Vector2 v11 = new Vector2(-v8.X, v8.Y);
                Vector2 v12 = new Vector2(-v7.X, v7.Y);
                Vector2 v13 = new Vector2(-v6.X, v6.Y);
                Vector2 v14 = new Vector2(-v5.X, v5.Y);
                Vector2 v15 = new Vector2(-v4.X, v4.Y);
                Vector2 v16 = new Vector2(-v3.X, v3.Y);
                Vector2 v17 = new Vector2(-v2.X, v2.Y);
                Vector2 v18 = new Vector2(-v1.X, v1.Y);
                Vector2 v19 = new Vector2(0, 2);
                Vector2 v20 = new Vector2(0, -oal - 2);
                //线段
                //主视图
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v7 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v7, v8 };
                fun.drawBLine(dxf, Line7, 0.5, contour);
                Vector2[] Line8 = { v8, v11 };
                fun.drawBLine(dxf, Line8, 0.5, contour);
                Vector2[] Line11 = { v11, v12 };
                fun.drawBLine(dxf, Line11, 0.5, contour);
                Vector2[] Line12 = { v12, v13 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v13, v14 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v14, v15 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v15, v16 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v16, v17 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v17, v18 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v18, v1 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v19, v20 };
                fun.drawPlinetype(dxf, Line19, 0.15, centre, Linetype.Center);
                Vector2[] Line20 = { v17, v2 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v16, v3 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v15, v4 };
                fun.drawBLine(dxf, Line22, 0.3, contour);
                Vector2[] Line23 = { v14, v5 };
                fun.drawBLine(dxf, Line23, 0.3, contour);
                Vector2[] Line24 = { v13, v6 };
                fun.drawBLine(dxf, Line24, 0.3, contour);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(v12, v7), -offset - apmx, 0, dimensionStyle);
                dim1.UserText = "DCN = " + Math.Round(dcn1 / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v11, v8), -offset * 2, 0, dimensionStyle);
                dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v7, v8), offset + (v8.X - v7.X) / 2, 270, dimensionStyle);
                dim3.UserText = "APMX = " + Math.Round(apmx / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v1, v3), offset + 0.25 + v8.X - v3.X, 270, dimensionStyle);
                dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v8, v1), offset * 2 + 0.25 + (v8.X - (v3.X + v7.X) / 2) / 2, 270, dimensionStyle);
                dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v17, v2), offset + 0.5, 0, dimensionStyle);
                dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                Angular2LineDimension angdim7 = new Angular2LineDimension(new Line(v7, v8), new Line(v12, v11), offset * 3 + dc / 2 * Math.Tan(prfa), dimensionStyle);
                angdim7.UserText = "PRFA = " + Math.Round(prfa / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim7);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v15, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
                dim8.UserText = "DN = " + Math.Round(dn / scale, 2);
                dxf.AddEntity(dim8);
                //图框
                if (isframe == 1)
                {
                    Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }
            if (btc == "02")
            {
                double h = re - Math.Sqrt(re * re - dc * dc / 4);
                Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(v1.X + 0.5, -0.5);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(dn / 2, v3.Y - (dconms - dn) / 2 * Math.Cos(45 * pi / 180) / Math.Sin(45 * pi / 180));
                Vector2 v5 = new Vector2(v4.X, -oal + apmx + (dconms - dn) / 2 * Math.Cos(45 * pi / 180) / Math.Sin(45 * pi / 180));
                Vector2 v6 = new Vector2(dc / 2, -oal + apmx);
                Vector2 v8 = new Vector2(v6.X, -oal + re - Math.Sqrt(re * re - dc * dc / 4));
                Vector2 v9 = new Vector2(-v8.X, v8.Y);
                Vector2 v11 = new Vector2(-v6.X, v6.Y);
                Vector2 v12 = new Vector2(-v5.X, v5.Y);
                Vector2 v13 = new Vector2(-v4.X, v4.Y);
                Vector2 v14 = new Vector2(-v3.X, v3.Y);
                Vector2 v15 = new Vector2(-v2.X, v2.Y);
                Vector2 v16 = new Vector2(-v1.X, v1.Y);
                Vector2 v17 = new Vector2(0, 2);
                Vector2 v18 = new Vector2(0, -oal - 2);
                //线段
                //主视图
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v8 };
                fun.drawBLine(dxf, Line6, 0.5, contour);
                LwPolyline Arc8 = new LwPolyline();
                Arc8.Vertexes.Add(new LwPolylineVertex(v9));
                Arc8.Vertexes.Add(new LwPolylineVertex(v8));
                Arc8.Vertexes[0].Bulge = (re - Math.Sqrt(re * re - dc * dc / 4)) * 2 / dc;
                fun.PolyFill(dxf, Arc8, 0.5, contour);
                Vector2[] Line9 = { v9, v11 };
                fun.drawBLine(dxf, Line9, 0.5, contour);
                Vector2[] Line11 = { v11, v12 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v12, v13 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v13, v14 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v14, v15 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v15, v16 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v16, v1 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v15, v2 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v14, v3 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v13, v4 };
                fun.drawBLine(dxf, Line19, 0.3, contour);
                Vector2[] Line20 = { v12, v5 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v17, v18 };
                fun.drawPlinetype(dxf, Line21, 0.15, centre, Linetype.Center);
                Vector2[] Line22 = { v11, v6 };
                fun.drawBLine(dxf, Line22, 0.3, contour);
                if (re * 2 != dc)
                {
                    Vector2[] Line23 = { v9, v8 };
                    fun.drawBLine(dxf, Line23, 0.3, contour);
                }
                Arc arc8 = new Arc(new Vector2(0, -oal + re), re, -(pi - Math.Atan((re - h) / v8.X)) / pi * 180, -Math.Atan((re - h) / v8.X) / pi * 180);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(v6, new Vector2(0, -oal)), offset + dc / 4, 270, dimensionStyle);
                dim1.UserText = "APMX = " + Math.Round(apmx / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v8, v9), -offset - (re - Math.Sqrt(re * re - dc * dc / 4)), 0, dimensionStyle);
                dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v1, v3), offset + 0.25 + v6.X - v3.X, 270, dimensionStyle);
                dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v1, new Vector2(0, -oal)), offset * 2 + 0.5 + v1.X / 2 + v6.X - v2.X, 270, dimensionStyle);
                dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v15, v2), offset + 0.5, 0, dimensionStyle);
                dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                LinearDimension dim7 = new LinearDimension(new Line(v13, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
                dim7.UserText = "DN = " + Math.Round(dn / scale, 2);
                dxf.AddEntity(dim7);
                //尺寸8
                RadialDimension dimrad8 = new RadialDimension(arc8, -100, offset, dimensionStyle);//DimensionStyle.Default);
                dimrad8.UserText = "RE = " + Math.Round(re / scale, 2);
                dxf.AddEntity(dimrad8);
                //图框
                if (isframe == 1)
                {
                    Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }
            if (btc == "04"||btc=="16")
            {
                double re1 = (dc / 2 - apmx * Math.Tan(prfa / 2)) * Math.Cos(prfa / 2) / (1 - Math.Sin(prfa / 2));
                Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(v1.X + 0.5, -0.5);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(dn / 2, v3.Y - (dconms - dn) / 2 * Math.Cos(45 * pi / 180) / Math.Sin(45 * pi / 180));
                Vector2 v5 = new Vector2(v4.X, -oal + apmx);
                Vector2 v8 = new Vector2(dc / 2, v5.Y);
                Vector2 v0 = new Vector2(0, -oal + re1);
                Vector2 v9 = new Vector2(re1 * Math.Cos(prfa / 2), -oal + re1 - Math.Sin(prfa / 2));
                Vector2 v10 = new Vector2(-v9.X, v9.Y);
                Vector2 v11 = new Vector2(-v8.X, v8.Y);
                Vector2 v12 = new Vector2(-v5.X, v5.Y);
                Vector2 v13 = new Vector2(-v4.X, v4.Y);
                Vector2 v14 = new Vector2(-v3.X, v3.Y);
                Vector2 v15 = new Vector2(-v2.X, v2.Y);
                Vector2 v16 = new Vector2(-v1.X, v1.Y);
                Vector2 v17 = new Vector2(0, 2);
                Vector2 v18 = new Vector2(0, -oal - 2);
                //线段
                //主视图
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v8, v11 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v8, v9 };
                fun.drawBLine(dxf, Line6, 0.5, contour);
                LwPolyline Arc7 = new LwPolyline();
                Arc7.Vertexes.Add(new LwPolylineVertex(v10));
                Arc7.Vertexes.Add(new LwPolylineVertex(v9));
                Arc7.Vertexes[0].Bulge = (v9.Y + oal) / v9.X;
                fun.PolyFill(dxf, Arc7, 0.5, contour);
                Vector2[] Line8 = { v10, v11 };
                fun.drawBLine(dxf, Line8, 0.5, contour);
                Vector2[] Line12 = { v12, v13 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v13, v14 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v14, v15 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v15, v16 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line18 = { v16, v1 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v15, v2 };
                fun.drawBLine(dxf, Line19, 0.3, contour);
                Vector2[] Line20 = { v14, v3 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v13, v4 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line24 = { v17, v18 };
                fun.drawPlinetype(dxf, Line24, 0.15, centre, Linetype.Center);
                Arc arc25 = new Arc(v0, re1, -(pi - prfa / 2) / pi * 180, -prfa / 2 / pi * 180);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v8, v11), -offset - apmx, 0, dimensionStyle);
                dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v8, new Vector2(0, -oal)), offset + v8.X / 2, 270, dimensionStyle);
                dim3.UserText = "APMX = " + Math.Round(apmx / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v1, v3), offset + 0.25 + v8.X - v3.X, 270, dimensionStyle);
                dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v1, new Vector2(0, -oal)), offset * 2 + 0.5 + v1.X / 2 + v8.X - v2.X, 270, dimensionStyle);
                dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v15, v2), offset + 0.5, 0, dimensionStyle);
                dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                LinearDimension dim7 = new LinearDimension(new Line(v13, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
                dim7.UserText = "DN = " + Math.Round(dn / scale, 2);
                dxf.AddEntity(dim7);
                //尺寸11
                RadialDimension dimrad11 = new RadialDimension(arc25, -100, offset, dimensionStyle);//DimensionStyle.Default);
                dimrad11.UserText = "RE = " + Math.Round(re1 / scale, 2);
                dxf.AddEntity(dimrad11);
                //尺寸12
                Angular2LineDimension angdim12 = new Angular2LineDimension(new Line(v10, v11), new Line(v9, v8), v8.X / Math.Tan(prfa / 2) - 5, dimensionStyle);
                angdim12.UserText = "PRFA = " + Math.Round(prfa / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim12);
                //图框
                if (isframe == 1)
                {
                    Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }
            if (btc == "26")
            {
                double l = Math.Sqrt((dcx - dc) * (dcx - dc) / 4 + apmx * apmx);
                double h = prfrad - Math.Sqrt(prfrad * prfrad - l * l / 4);
                double a1 = Math.Atan(l / 2 / (prfrad - h));
                double a2 = Math.Atan(apmx / (dcx - dc) * 2);
                Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(v1.X + 0.5, -0.5);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(dn / 2, v3.Y - (dconms - dn) / 2 * Math.Cos(45 * pi / 180) / Math.Sin(45 * pi / 180));
                Vector2 v6 = new Vector2(v4.X, -oal + lh);
                Vector2 v7 = new Vector2(dcx / 2, v6.Y);
                Vector2 v8 = new Vector2(v7.X, -oal + apmx);
                Vector2 v9 = new Vector2(dc / 2, -oal);
                Vector2 v10 = new Vector2(-v9.X, v9.Y);
                Vector2 v11 = new Vector2(-v8.X, v8.Y);
                Vector2 v12 = new Vector2(-v7.X, v7.Y);
                Vector2 v13 = new Vector2(-v6.X, v6.Y);
                Vector2 v15 = new Vector2(-v4.X, v4.Y);
                Vector2 v16 = new Vector2(-v3.X, v3.Y);
                Vector2 v17 = new Vector2(-v2.X, v2.Y);
                Vector2 v18 = new Vector2(-v1.X, v1.Y);
                Vector2 v19 = new Vector2(0, 2);
                Vector2 v20 = new Vector2(0, -oal - 2);
                Vector2 v21 = new Vector2(v9.X + prfrad * Math.Cos(pi / 2 - a1 - a2), v9.Y - prfrad * Math.Sin(pi / 2 - a1 - a2));
                //线段
                //主视图
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v6 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line6 = { v6, v7 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v7, v8 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                LwPolyline Arc8 = new LwPolyline();
                Arc8.Vertexes.Add(new LwPolylineVertex(v8));
                Arc8.Vertexes.Add(new LwPolylineVertex(v9));
                Arc8.Vertexes[0].Bulge = h * 2 / l;
                fun.PolyFill(dxf, Arc8, 0.5, contour);
                Vector2[] Line9 = { v9, v10 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                LwPolyline Arc10 = new LwPolyline();
                Arc10.Vertexes.Add(new LwPolylineVertex(v10));
                Arc10.Vertexes.Add(new LwPolylineVertex(v11));
                Arc10.Vertexes[0].Bulge = h * 2 / l;
                fun.PolyFill(dxf, Arc10, 0.5, contour);
                Vector2[] Line11 = { v11, v12 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v12, v13 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v13, v15 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line15 = { v15, v16 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v16, v17 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v17, v18 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v18, v1 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v19, v20 };
                fun.drawPlinetype(dxf, Line19, 0.15, centre, Linetype.Center);
                Vector2[] Line20 = { v17, v2 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v16, v3 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v15, v4 };
                fun.drawBLine(dxf, Line22, 0.3, contour);
                Vector2[] Line24 = { v13, v6 };
                fun.drawBLine(dxf, Line24, 0.3, contour);
                Vector2[] Line25 = { v11, v8 };
                fun.drawBLine(dxf, Line25, 0.3, contour);
                Arc arc8 = new Arc(v21, prfrad, (pi / 2 + a2 - a1) / pi * 180, (pi / 2 + a1 + a2) / pi * 180);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(v11, v8), -offset * 2 - apmx, 0, dimensionStyle);
                dim1.UserText = "DCX = " + Math.Round(dcx / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v10, v9), -offset, 0, dimensionStyle);
                dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v9, v8), offset + (v8.X - v9.X) / 2, 270, dimensionStyle);
                dim3.UserText = "APMX = " + Math.Round(apmx / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v1, v3), offset + 0.25 + v7.X - v3.X, 270, dimensionStyle);
                dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v9, v1), offset * 3 + 0.25 + v7.X - (v3.X + v9.X) / 2, 270, dimensionStyle);
                dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v17, v2), offset + 0.5, 0, dimensionStyle);
                dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                RadialDimension dimrad7 = new RadialDimension(arc8, 135, offset / 2, dimensionStyle);//DimensionStyle.Default);
                dimrad7.UserText = "PRFRAD = " + Math.Round(prfrad / scale, 2);
                dxf.AddEntity(dimrad7);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v15, v4), -(v4.Y - v6.Y) / 2, 0, dimensionStyle);
                dim8.UserText = "DN = " + Math.Round(dn / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v7, v9), offset * 2 + (v7.X - v9.X) / 2, 270, dimensionStyle);
                dim9.UserText = "LH = " + Math.Round(lh / scale, 2);
                dxf.AddEntity(dim9);
                //图框
                if (isframe == 1)
                {
                    Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }
            if (btc == "25")
            {
                double a = Math.Acos((dcn / 2 + prfrad - dc / 2) / prfrad);
                Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(v1.X + 0.5, -0.5);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(dn / 2, v3.Y - (dconms - dn) / 2 * Math.Cos(45 * pi / 180) / Math.Sin(45 * pi / 180));
                Vector2 v5 = new Vector2(v4.X, -oal + lh);
                Vector2 v6 = new Vector2(dcn / 2, -oal + lh);
                Vector2 v8 = new Vector2(dc / 2, v6.Y - apmx);
                Vector2 v7 = new Vector2(v6.X, v8.Y + prfrad * Math.Sin(a));
                Vector2 v9 = new Vector2(dc / 2, -oal);
                Vector2 v10 = new Vector2(-v9.X, v9.Y);
                Vector2 v11 = new Vector2(-v8.X, v8.Y);
                Vector2 v12 = new Vector2(-v7.X, v7.Y);
                Vector2 v13 = new Vector2(-v6.X, v6.Y);
                Vector2 v14 = new Vector2(-v5.X, v5.Y);
                Vector2 v15 = new Vector2(-v4.X, v4.Y);
                Vector2 v16 = new Vector2(-v3.X, v3.Y);
                Vector2 v17 = new Vector2(-v2.X, v2.Y);
                Vector2 v18 = new Vector2(-v1.X, v1.Y);
                Vector2 v19 = new Vector2(0, 2);
                Vector2 v20 = new Vector2(0, -oal - 2);
                Vector2 v21 = new Vector2(v12.X - prfrad, v12.Y);
                //线段
                //主视图
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v7 };
                fun.drawBLine(dxf, Line6, 0.5, contour);
                Vector2[] Line7 = { v9, v8 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                LwPolyline Arc8 = new LwPolyline();
                Arc8.Vertexes.Add(new LwPolylineVertex(v7));
                Arc8.Vertexes.Add(new LwPolylineVertex(v8));
                Arc8.Vertexes[0].Bulge = Math.Tan(a / 4);
                fun.PolyFill(dxf, Arc8, 0.5, contour);
                Vector2[] Line9 = { v9, v10 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                LwPolyline Arc10 = new LwPolyline();
                Arc10.Vertexes.Add(new LwPolylineVertex(v11));
                Arc10.Vertexes.Add(new LwPolylineVertex(v12));
                Arc10.Vertexes[0].Bulge = Math.Tan(a / 4);
                fun.PolyFill(dxf, Arc10, 0.5, contour);
                Vector2[] Line11 = { v11, v10 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v12, v13 };
                fun.drawBLine(dxf, Line12, 0.5, contour);
                Vector2[] Line13 = { v13, v14 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v15, v14 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v15, v16 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v16, v17 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v17, v18 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v18, v1 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v19, v20 };
                fun.drawPlinetype(dxf, Line19, 0.15, centre, Linetype.Center);
                Vector2[] Line20 = { v17, v2 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v16, v3 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v15, v4 };
                fun.drawBLine(dxf, Line22, 0.3, contour);
                Vector2[] Line24 = { v14, v5 };
                fun.drawBLine(dxf, Line24, 0.3, contour);
                Vector2[] Line25 = { v11, v8 };
                fun.drawBLine(dxf, Line25, 0.3, contour);
                Arc arc8 = new Arc(v21, prfrad, 0, -a * 180 / pi);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(v12, v7), -offset - v7.Y + v9.Y, 0, dimensionStyle);
                dim1.UserText = "DCN = " + Math.Round(dcn / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v10, v9), -offset * 2, 0, dimensionStyle);
                dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v6, v8), offset + (v8.X - v6.X) / 2, 270, dimensionStyle);
                dim3.UserText = "APMX = " + Math.Round(apmx / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v1, v3), offset + 0.25 + v9.X - v3.X, 270, dimensionStyle);
                dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v9, v1), offset * 3 + 0.25 + (v9.X - v3.X) / 2, 270, dimensionStyle);
                dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v17, v2), offset + 0.5, 0, dimensionStyle);
                dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                RadialDimension dimrad7 = new RadialDimension(arc8, -20, offset / 2, dimensionStyle);//DimensionStyle.Default);
                dimrad7.UserText = "PRFRAD = " + Math.Round(prfrad / scale, 2);
                dxf.AddEntity(dimrad7);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v15, v4), -(v4.Y - v6.Y) / 2, 0, dimensionStyle);
                dim8.UserText = "DN = " + Math.Round(dn / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v6, v9), offset * 2 + (v9.X - v6.X) / 2, 270, dimensionStyle);
                dim9.UserText = "LH = " + Math.Round(lh / scale, 2);
                dxf.AddEntity(dim9);
                //图框
                if (isframe == 1)
                {
                    Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }
            if (btc=="08")
            {
                double re1 = dc / 2;
                Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(v1.X + 0.5, -0.5);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(dn / 2, v3.Y - (dconms - dn) / 2 * Math.Cos(45 * pi / 180) / Math.Sin(45 * pi / 180));
                Vector2 v5 = new Vector2(v4.X, -oal + apmx);
                Vector2 v7 = new Vector2(Math.Sqrt(re1 * re1 - (apmx - re1) * (apmx - re1)), -oal + apmx);
                Vector2 v8 = new Vector2(-v7.X, v7.Y);
                Vector2 v10 = new Vector2(-v5.X, v5.Y);
                Vector2 v11 = new Vector2(-v4.X, v4.Y);
                Vector2 v12 = new Vector2(-v3.X, v3.Y);
                Vector2 v13 = new Vector2(-v2.X, v2.Y);
                Vector2 v14 = new Vector2(-v1.X, v1.Y);
                Vector2 v15 = new Vector2(0, 2);
                Vector2 v16 = new Vector2(0, -oal - 2);
                //线段
                //主视图
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                //Vector2[] Line5 = { v5, v7 };
                //fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v8, v7 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                LwPolyline Arc8 = new LwPolyline();
                Arc8.Vertexes.Add(new LwPolylineVertex(v7));
                Arc8.Vertexes.Add(new LwPolylineVertex(v8));
                Arc8.Vertexes[0].Bulge = -apmx / v7.X;
                fun.PolyFill(dxf, Arc8, 0.5, contour);
                //Vector2[] Line9 = { v8, v10 };
                //fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v11, v10 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v11, v12 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v12, v13 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v13, v14 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v14, v1 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line17 = { v13, v2 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v12, v3 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v11, v4 };
                fun.drawBLine(dxf, Line19, 0.3, contour);
                Vector2[] Line20 = { v10, v5 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v15, v16 };
                fun.drawPlinetype(dxf, Line21, 0.15, centre, Linetype.Center);
                Arc arc8 = new Arc(new Vector2(0, -oal + re1), re1, (pi / 2 + Math.Atan(v7.X / (apmx - re1))) / pi * 180, (pi / 2 - Math.Atan(v7.X / (apmx - re1))) / pi * 180);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(v7, new Vector2(0, -oal)), offset + dc / 2 - v7.X / 2, 270, dimensionStyle);
                dim1.UserText = "APMX = " + Math.Round(apmx / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(new Vector2(-dc / 2, -oal + re1), new Vector2(dc / 2, -oal + re1)), -offset - re1, 0, dimensionStyle);
                dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v1, v3), offset + 0.25 + dc / 2 - v3.X, 270, dimensionStyle);
                dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v1, new Vector2(0, -oal)), offset * 2 + 0.5 + v1.X / 2 + dc / 2 - v2.X, 270, dimensionStyle);
                dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v13, v2), offset + 0.5, 0, dimensionStyle);
                dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                LinearDimension dim7 = new LinearDimension(new Line(v11, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
                dim7.UserText = "DN = " + Math.Round(dn / scale, 2);
                dxf.AddEntity(dim7);
                //尺寸8
                RadialDimension dimrad8 = new RadialDimension(arc8, -100, offset, dimensionStyle);//DimensionStyle.Default);
                dimrad8.UserText = "RE = " + Math.Round(re1 / scale, 2);
                dxf.AddEntity(dimrad8);
                //图框
                if (isframe == 1)
                {
                    Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }
            if (btc=="10" || btc == "11" || btc == "12" || btc == "18")
            {
                Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(v1.X + 0.5, -0.5);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(dn / 2, v3.Y - (dconms - dn) / 2 * Math.Cos(45 * pi / 180) / Math.Sin(45 * pi / 180));
                Vector2 v5 = new Vector2(v4.X, -oal + apmx);
                Vector2 v8 = new Vector2(re * (prfrad - dc / 2) / (prfrad - re), -oal + re - re * Math.Sin(Math.Acos((prfrad - dc / 2) / (prfrad - re))));
                Vector2 v9 = new Vector2(-v8.X, v8.Y);
                Vector2 v7 = new Vector2(dc / 2, -oal + re + Math.Sqrt((prfrad - re) * (prfrad - re) - (prfrad - dc / 2) * (prfrad - dc / 2)));
                Vector2 v10 = new Vector2(-v7.X, v7.Y);
                Vector2 v11 = new Vector2(-dc / 2 + prfrad - Math.Sqrt(prfrad * prfrad - (apmx - re - Math.Sqrt((prfrad - re) * (prfrad - re) - (prfrad - dc / 2) * (prfrad - dc / 2))) * (apmx - re - Math.Sqrt((prfrad - re) * (prfrad - re) - (prfrad - dc / 2) * (prfrad - dc / 2)))), -oal + apmx);
                Vector2 v6 = new Vector2(-v11.X, v11.Y);
                Vector2 v12 = new Vector2(-v5.X, v5.Y);
                Vector2 v13 = new Vector2(-v4.X, v4.Y);
                Vector2 v14 = new Vector2(-v3.X, v3.Y);
                Vector2 v15 = new Vector2(-v2.X, v2.Y);
                Vector2 v16 = new Vector2(-v1.X, v1.Y);
                Vector2 v17 = new Vector2(0, 2);
                Vector2 v18 = new Vector2(0, -oal - 2);
                //线段
                //主视图
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line6 = { v6, v11 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                LwPolyline Arc8 = new LwPolyline();
                Arc8.Vertexes.Add(new LwPolylineVertex(v6));
                Arc8.Vertexes.Add(new LwPolylineVertex(v8));
                Arc8.Vertexes[0].Bulge = -Math.Tan(Math.Asin(Math.Sqrt((v9.X - v11.X) * (v9.X - v11.X) + (v11.Y - v9.Y) * (v11.Y - v9.Y)) / 2 / prfrad) / 2);
                fun.PolyFill(dxf, Arc8, 0.5, contour);
                LwPolyline Arc9 = new LwPolyline();
                Arc9.Vertexes.Add(new LwPolylineVertex(v9));
                Arc9.Vertexes.Add(new LwPolylineVertex(v11));
                Arc9.Vertexes[0].Bulge = -Math.Tan(Math.Asin(Math.Sqrt((v9.X - v11.X) * (v9.X - v11.X) + (v11.Y - v9.Y) * (v11.Y - v9.Y)) / 2 / prfrad) / 2);
                fun.PolyFill(dxf, Arc9, 0.5, contour);
                LwPolyline Arc10 = new LwPolyline();
                Arc10.Vertexes.Add(new LwPolylineVertex(v9));
                Arc10.Vertexes.Add(new LwPolylineVertex(v8));
                Arc10.Vertexes[0].Bulge = (v8.Y + oal) / v8.X;
                fun.PolyFill(dxf, Arc10, 0.5, contour);
                Vector2[] Line7 = { v14, v15 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line11 = { v15, v16 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v12, v13 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v13, v14 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v16, v1 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line17 = { v15, v2 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v14, v3 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v13, v4 };
                fun.drawBLine(dxf, Line19, 0.3, contour);
                Vector2[] Line21 = { v17, v18 };
                fun.drawPlinetype(dxf, Line21, 0.15, centre, Linetype.Center);
                Arc arc15 = new Arc(new Vector2(0, -oal + re), re, -(pi - Math.Acos(v8.X / re)) / pi * 180, -Math.Acos(v8.X / re) / pi * 180);
                Arc arc16 = new Arc(new Vector2(v10.X + prfrad, v10.Y), prfrad, (pi - Math.Asin((v11.Y - v10.Y) / prfrad)) / pi * 180, (pi + Math.Acos(v8.X / re)) / pi * 180);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(v6, new Vector2(0, -oal)), offset + dc / 2 - v6.X / 2, 270, dimensionStyle);
                dim1.UserText = "APMX = " + Math.Round(apmx / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v10, v7), -offset - v7.Y - oal, 0, dimensionStyle);
                dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v1, v3), offset + 0.25 + dc / 2 - v3.X, 270, dimensionStyle);
                dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v1, new Vector2(0, -oal)), offset * 2 + 0.5 + v1.X / 2 + dc / 2 - v2.X, 270, dimensionStyle);
                dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v15, v2), offset + 0.5, 0, dimensionStyle);
                dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                LinearDimension dim7 = new LinearDimension(new Line(v13, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
                dim7.UserText = "DN = " + Math.Round(dn / scale, 2);
                dxf.AddEntity(dim7);
                //尺寸8
                RadialDimension dimrad8 = new RadialDimension(arc15, -100, -re - offset, dimensionStyle);//DimensionStyle.Default);
                dimrad8.UserText = "RE = " + Math.Round(re / scale, 2);
                dxf.AddEntity(dimrad8);
                //尺寸9
                RadialDimension dimrad9 = new RadialDimension(arc16, 200, prfrad + offset, dimensionStyle);//DimensionStyle.Default);
                dimrad9.UserText = "PRFRAD = " + Math.Round(prfrad / scale, 2);
                dxf.AddEntity(dimrad9);
                //图框
                if (isframe == 1)
                {
                    Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }
            if (btc == "09" || btc == "13" || btc == "14" || btc == "17")
            {
                Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(v1.X + 0.5, -0.5);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(dn / 2, v3.Y - (dconms - dn) / 2 * Math.Cos(45 * pi / 180) / Math.Sin(45 * pi / 180));
                Vector2 v5 = new Vector2(v4.X, -oal + apmx);
                Vector2 v8 = new Vector2(0, -oal);
                Vector2 v10 = new Vector2(-dc / 2, -oal + Math.Sqrt(prfrad * prfrad - (prfrad - dc / 2) * (prfrad - dc / 2)));
                Vector2 v7 = new Vector2(-v10.X, v10.Y);
                Vector2 v11 = new Vector2(-dc / 2 + prfrad - Math.Sqrt(prfrad * prfrad - (apmx - Math.Sqrt(prfrad * prfrad - (prfrad - dc / 2) * (prfrad - dc / 2))) * (apmx - Math.Sqrt(prfrad * prfrad - (prfrad - dc / 2) * (prfrad - dc / 2)))), -oal + apmx);
                Vector2 v6 = new Vector2(-v11.X, v11.Y);
                Vector2 v12 = new Vector2(-v5.X, v5.Y);
                Vector2 v13 = new Vector2(-v4.X, v4.Y);
                Vector2 v14 = new Vector2(-v3.X, v3.Y);
                Vector2 v15 = new Vector2(-v2.X, v2.Y);
                Vector2 v16 = new Vector2(-v1.X, v1.Y);
                Vector2 v17 = new Vector2(0, 2);
                Vector2 v18 = new Vector2(0, -oal - 2);
                //线段
                //主视图
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line6 = { v6, v11 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                LwPolyline Arc8 = new LwPolyline();
                Arc8.Vertexes.Add(new LwPolylineVertex(v6));
                Arc8.Vertexes.Add(new LwPolylineVertex(v8));
                Arc8.Vertexes[0].Bulge = -Math.Tan(Math.Asin(Math.Sqrt((v8.X - v11.X) * (v8.X - v11.X) + (v11.Y - v8.Y) * (v11.Y - v8.Y)) / 2 / prfrad) / 2);
                fun.PolyFill(dxf, Arc8, 0.5, contour);
                LwPolyline Arc9 = new LwPolyline();
                Arc9.Vertexes.Add(new LwPolylineVertex(v8));
                Arc9.Vertexes.Add(new LwPolylineVertex(v11));
                Arc9.Vertexes[0].Bulge = -Math.Tan(Math.Asin(Math.Sqrt((v8.X - v11.X) * (v8.X - v11.X) + (v11.Y - v8.Y) * (v11.Y - v8.Y)) / 2 / prfrad) / 2);
                fun.PolyFill(dxf, Arc9, 0.5, contour);
                Vector2[] Line7 = { v14, v15 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line11 = { v15, v16 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v12, v13 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v13, v14 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v16, v1 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line17 = { v15, v2 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v14, v3 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v13, v4 };
                fun.drawBLine(dxf, Line19, 0.3, contour);
                Vector2[] Line21 = { v17, v18 };
                fun.drawPlinetype(dxf, Line21, 0.15, centre, Linetype.Center);
                Arc arc16 = new Arc(new Vector2(-dc / 2 + prfrad, -oal + Math.Sqrt(prfrad * prfrad - (prfrad - dc / 2) * (prfrad - dc / 2))), prfrad, (pi - Math.Asin((v11.Y - (-oal + Math.Sqrt(prfrad * prfrad - (prfrad - dc / 2) * (prfrad - dc / 2)))) / prfrad)) / pi * 180, -90);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(v6, new Vector2(0, -oal)), offset + dc / 2 - v6.X / 2, 270, dimensionStyle);
                dim1.UserText = "APMX = " + Math.Round(apmx / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v10, v7), -offset - v7.Y - oal, 0, dimensionStyle);
                dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v1, v3), offset + 0.25 + dc / 2 - v3.X, 270, dimensionStyle);
                dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v1, new Vector2(0, -oal)), offset * 2 + 0.5 + v1.X / 2 + dc / 2 - v2.X, 270, dimensionStyle);
                dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v15, v2), offset + 0.5, 0, dimensionStyle);
                dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                LinearDimension dim7 = new LinearDimension(new Line(v13, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
                dim7.UserText = "DN = " + Math.Round(dn / scale, 2);
                dxf.AddEntity(dim7);
                //尺寸9
                RadialDimension dimrad9 = new RadialDimension(arc16, 200, prfrad + offset, dimensionStyle);//DimensionStyle.Default);
                dimrad9.UserText = "PRFRAD = " + Math.Round(prfrad / scale, 2);
                dxf.AddEntity(dimrad9);
                //图框
                if (isframe == 1)
                {
                    Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }
            if (btc == "03" || btc == "05" || btc == "06" || btc == "15")
            {
                double apmx1 = dc / 2 / Math.Tan(prfa / 2);
                Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(v1.X + 0.5, -0.5);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(dn / 2, v3.Y - (dconms - dn) / 2 * Math.Cos(45 * pi / 180) / Math.Sin(45 * pi / 180));
                Vector2 v5 = new Vector2(v4.X, -oal + lh);
                Vector2 v6 = new Vector2(dc / 2, v5.Y);
                Vector2 v7 = new Vector2(v6.X, -oal + apmx1);
                Vector2 v8 = new Vector2(0, -oal);
                Vector2 v9 = new Vector2(-v7.X, v7.Y);
                Vector2 v10 = new Vector2(-v6.X, v6.Y);
                Vector2 v11 = new Vector2(-v5.X, v5.Y);
                Vector2 v12 = new Vector2(-v4.X, v4.Y);
                Vector2 v13 = new Vector2(-v3.X, v3.Y);
                Vector2 v14 = new Vector2(-v2.X, v2.Y);
                Vector2 v15 = new Vector2(-v1.X, v1.Y);
                Vector2 v16 = new Vector2(0, 2);
                Vector2 v17 = new Vector2(0, -oal - 2);
                //线段
                //主视图
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v6, v7 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v10 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v14, v15 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v7, v8 };
                fun.drawBLine(dxf, Line8, 0.5, contour);
                Vector2[] Line9 = { v8, v9 };
                fun.drawBLine(dxf, Line9, 0.5, contour);
                Vector2[] Line10 = { v9, v10 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v11, v12 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v12, v13 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v13, v14 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line15 = { v14, v15 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line14 = { v15, v1 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line17 = { v14, v2 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v13, v3 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v12, v4 };
                fun.drawBLine(dxf, Line19, 0.3, contour);
                Vector2[] Line20 = { v9, v7 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v16, v17 };
                fun.drawPlinetype(dxf, Line21, 0.15, centre, Linetype.Center);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(v7, v8), offset + v7.X / 2, 270, dimensionStyle);
                dim1.UserText = "APMX = " + Math.Round(apmx1 / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v9, v7), -offset - v7.Y - oal, 0, dimensionStyle);
                dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v1, v3), offset + 0.25 + dc / 2 - v3.X, 270, dimensionStyle);
                dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v1, v8), offset * 2 + 0.5 + v2.X / 2, 270, dimensionStyle);
                dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v14, v2), offset + 0.5, 0, dimensionStyle);
                dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                LinearDimension dim7 = new LinearDimension(new Line(v12, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
                dim7.UserText = "DN = " + Math.Round(dn / scale, 2);
                dxf.AddEntity(dim7);
                //尺寸8
                Angular2LineDimension angdim8 = new Angular2LineDimension(new Line(v8, v7), new Line(v8, v9), apmx1, dimensionStyle);
                angdim8.UserText = "PRFA = " + Math.Round(prfa / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim8);
                //图框
                if (isframe == 1)
                {
                    Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }
            if (btc == "19")
            {
                Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(v1.X + 0.5, -0.5);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(dn / 2, v3.Y - (dconms - dn) / 2 * Math.Cos(45 * pi / 180) / Math.Sin(45 * pi / 180));
                Vector2 v5 = new Vector2(v4.X, -oal + apmx);
                Vector2 v6 = new Vector2(dc / 2 - re + Math.Sqrt(re * re - apmx * apmx / 4), v5.Y);
                Vector2 v7 = new Vector2(v6.X, -oal);
                Vector2 v8 = new Vector2(-v7.X, v7.Y);
                Vector2 v9 = new Vector2(-v6.X, v6.Y);
                Vector2 v10 = new Vector2(-v5.X, v5.Y);
                Vector2 v11 = new Vector2(-v4.X, v4.Y);
                Vector2 v12 = new Vector2(-v3.X, v3.Y);
                Vector2 v13 = new Vector2(-v2.X, v2.Y);
                Vector2 v14 = new Vector2(-v1.X, v1.Y);
                Vector2 v15 = new Vector2(0, 2);
                Vector2 v16 = new Vector2(0, -oal - 2);
                //线段
                //主视图
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line6 = { v6, v9 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                LwPolyline Arc8 = new LwPolyline();
                Arc8.Vertexes.Add(new LwPolylineVertex(v7));
                Arc8.Vertexes.Add(new LwPolylineVertex(v6));
                Arc8.Vertexes[0].Bulge = (dc / 2 - v6.X) * 2 / apmx;
                fun.PolyFill(dxf, Arc8, 0.5, contour);
                LwPolyline Arc9 = new LwPolyline();
                Arc9.Vertexes.Add(new LwPolylineVertex(v9));
                Arc9.Vertexes.Add(new LwPolylineVertex(v8));
                Arc9.Vertexes[0].Bulge = (dc / 2 - v6.X) * 2 / apmx;
                fun.PolyFill(dxf, Arc9, 0.5, contour);
                Vector2[] Line7 = { v7, v8 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v11, v12 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line11 = { v10, v11 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v12, v13 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v13, v14 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v14, v1 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line17 = { v13, v2 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v12, v3 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v11, v4 };
                fun.drawBLine(dxf, Line19, 0.3, contour);
                Vector2[] Line21 = { v15, v16 };
                fun.drawPlinetype(dxf, Line21, 0.15, centre, Linetype.Center);
                Arc arc16 = new Arc(new Vector2(-dc / 2 + re, -oal + apmx / 2), re, (pi / 2 + Math.Acos(apmx / 2 / re)) / pi * 180, (pi * 3 / 2 - Math.Acos(apmx / 2 / re)) / pi * 180);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(v6, v7), offset + dc / 2 - v6.X, 270, dimensionStyle);
                dim1.UserText = "APMX = " + Math.Round(apmx / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(new Vector2(-dc / 2, -oal + apmx / 2), new Vector2(dc / 2, -oal + apmx / 2)), -offset - apmx / 2, 0, dimensionStyle);
                dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v1, v3), offset + 0.25 + dc / 2 - v3.X, 270, dimensionStyle);
                dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v1, v7), offset * 2 + dc / 2 - (v1.X + v7.X) / 2, 270, dimensionStyle);
                dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v13, v2), offset + 0.5, 0, dimensionStyle);
                dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                LinearDimension dim7 = new LinearDimension(new Line(v11, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
                dim7.UserText = "DN = " + Math.Round(dn / scale, 2);
                dxf.AddEntity(dim7);
                //尺寸9
                RadialDimension dimrad9 = new RadialDimension(arc16, 200, re + offset, dimensionStyle);//DimensionStyle.Default);
                dimrad9.UserText = "RE = " + Math.Round(re / scale, 2);
                dxf.AddEntity(dimrad9);
                //图框
                if (isframe == 1)
                {
                    Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }
            if (btc == "20")
            {
                Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(v1.X + 0.5, -0.5);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(dn / 2, v3.Y - (dconms - dn) / 2 * Math.Cos(45 * pi / 180) / Math.Sin(45 * pi / 180));
                Vector2 v5 = new Vector2(v4.X, -oal + apmx);
                Vector2 v6 = new Vector2(dc / 2 - apmx / 2 / Math.Tan(pna / 2), v5.Y);
                Vector2 v7 = new Vector2(v6.X, -oal);
                Vector2 v8 = new Vector2(-v7.X, v7.Y);
                Vector2 v9 = new Vector2(-v6.X, v6.Y);
                Vector2 v10 = new Vector2(-v5.X, v5.Y);
                Vector2 v11 = new Vector2(-v4.X, v4.Y);
                Vector2 v12 = new Vector2(-v3.X, v3.Y);
                Vector2 v13 = new Vector2(-v2.X, v2.Y);
                Vector2 v14 = new Vector2(-v1.X, v1.Y);
                Vector2 v15 = new Vector2(0, 2);
                Vector2 v16 = new Vector2(0, -oal - 2);
                Vector2 v17 = new Vector2(dc / 2, -oal + apmx / 2);
                Vector2 v18 = new Vector2(-v17.X, v17.Y);
                //线段
                //主视图
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line6 = { v6, v9 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v7, v8 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v11, v12 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v6, v17 };
                fun.drawBLine(dxf, Line9, 0.5, contour);
                Vector2[] Line10 = { v17, v7 };
                fun.drawBLine(dxf, Line10, 0.5, contour);
                Vector2[] Line11 = { v10, v11 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v12, v13 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v13, v14 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v14, v1 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v8, v18 };
                fun.drawBLine(dxf, Line15, 0.5, contour);
                Vector2[] Line16 = { v9, v18 };
                fun.drawBLine(dxf, Line16, 0.5, contour);
                Vector2[] Line17 = { v13, v2 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v12, v3 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v11, v4 };
                fun.drawBLine(dxf, Line19, 0.3, contour);
                Vector2[] Line21 = { v15, v16 };
                fun.drawPlinetype(dxf, Line21, 0.15, centre, Linetype.Center);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(v6, v7), offset + v17.X - v6.X, 270, dimensionStyle);
                dim1.UserText = "APMX = " + Math.Round(apmx / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v18, v17), -offset - apmx / 2, 0, dimensionStyle);
                dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v1, v3), offset + 0.25 + v17.X - v3.X, 270, dimensionStyle);
                dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v1, v7), offset * 2 + v17.X - (v1.X + v7.X) / 2, 270, dimensionStyle);
                dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v13, v2), offset + 0.5, 0, dimensionStyle);
                dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                LinearDimension dim7 = new LinearDimension(new Line(v11, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
                dim7.UserText = "DN = " + Math.Round(dn / scale, 2);
                dxf.AddEntity(dim7);
                //尺寸8
                Angular2LineDimension angdim8 = new Angular2LineDimension(new Line(v17, v6), new Line(v17, v7), offset, dimensionStyle);
                angdim8.UserText = "PNA = " + Math.Round(pna / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim8);
                //图框
                if (isframe == 1)
                {
                    Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }
            if (btc == "22")
            {
                double apmx1 = prfrad - 2 * Math.Sqrt(prfrad * prfrad - dc * dc / 4) + Math.Sqrt(prfrad * prfrad - dn * dn / 4);
                Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(v1.X + 0.5, -0.5);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(dn / 2, v3.Y - (dconms - dn) / 2 * Math.Cos(45 * pi / 180) / Math.Sin(45 * pi / 180));
                Vector2 v5 = new Vector2(v4.X, -oal + apmx1);
                Vector2 v6 = new Vector2(dc / 2, -oal + prfrad - Math.Sqrt(prfrad * prfrad - dc * dc / 4));
                Vector2 v7 = new Vector2(-v6.X, v6.Y);
                Vector2 v8 = new Vector2(-v5.X, v5.Y);
                Vector2 v9 = new Vector2(-v4.X, v4.Y);
                Vector2 v10 = new Vector2(-v3.X, v3.Y);
                Vector2 v11 = new Vector2(-v2.X, v2.Y);
                Vector2 v12 = new Vector2(-v1.X, v1.Y);
                Vector2 v13 = new Vector2(0, 2);
                Vector2 v14 = new Vector2(0, -oal - 2);
                Vector2 v15 = new Vector2(0, -oal + prfrad);
                //线段
                //主视图
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line6 = { v5, v8 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v8, v9 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v11, v12 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v9, v10 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line11 = { v10, v11 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line14 = { v12, v1 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line17 = { v11, v2 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v10, v3 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v9, v4 };
                fun.drawBLine(dxf, Line19, 0.3, contour);
                Vector2[] Line21 = { v13, v14 };
                fun.drawPlinetype(dxf, Line21, 0.15, centre, Linetype.Center);
                LwPolyline Arc10 = new LwPolyline();
                Arc10.Vertexes.Add(new LwPolylineVertex(v7));
                Arc10.Vertexes.Add(new LwPolylineVertex(v6));
                Arc10.Vertexes[0].Bulge = (oal + v6.Y) * 2 / dc;
                fun.PolyFill(dxf, Arc10, 0.5, contour);
                LwPolyline Arc12 = new LwPolyline();
                Arc12.Vertexes.Add(new LwPolylineVertex(v6));
                Arc12.Vertexes.Add(new LwPolylineVertex(v5));
                Arc12.Vertexes[0].Bulge = Math.Tan((Math.Asin(dc / 2 / prfrad) - Math.Asin(dn / 2 / prfrad)) / 4);
                fun.PolyFill(dxf, Arc12, 0.5, contour);
                LwPolyline Arc13 = new LwPolyline();
                Arc13.Vertexes.Add(new LwPolylineVertex(v8));
                Arc13.Vertexes.Add(new LwPolylineVertex(v7));
                Arc13.Vertexes[0].Bulge = Math.Tan((Math.Asin(dc / 2 / prfrad) - Math.Asin(dn / 2 / prfrad)) / 4);
                fun.PolyFill(dxf, Arc13, 0.5, contour);
                Arc arc16 = new Arc(v15, prfrad, -(pi / 2 + Math.Asin(dc / 2 / prfrad)) / pi * 180, -(pi / 2 + Math.Asin(dc / 2 / prfrad)) / pi * 180);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(v5, new Vector2(0, -oal)), offset - v5.X / 2 + v6.X, 270, dimensionStyle);
                dim1.UserText = "APMX = " + Math.Round(apmx1 / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v7, v6), -offset - oal - v6.Y, 0, dimensionStyle);
                dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v1, v3), offset + 0.25 + v6.X - v3.X, 270, dimensionStyle);
                dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v1, new Vector2(0, -oal)), offset * 2 + v6.X - v1.X / 2, 270, dimensionStyle);
                dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v11, v2), offset + 0.5, 0, dimensionStyle);
                dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                LinearDimension dim7 = new LinearDimension(new Line(v9, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
                dim7.UserText = "DN = " + Math.Round(dn / scale, 2);
                dxf.AddEntity(dim7);
                //尺寸9
                RadialDimension dimrad9 = new RadialDimension(arc16, -100, -offset + prfrad, dimensionStyle);//DimensionStyle.Default);
                dimrad9.UserText = "PRFRAD = " + Math.Round(prfrad / scale, 2);
                dxf.AddEntity(dimrad9);
                //图框
                if (isframe == 1)
                {
                    Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }
            if (btc == "23")
            {
                double re1 = dc1 / 2;
                Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(v1.X + 0.5, -0.5);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(dn / 2, v3.Y - (dconms - dn) / 2 * Math.Cos(45 * pi / 180) / Math.Sin(45 * pi / 180));
                Vector2 v5 = new Vector2(v4.X, -oal + apmx);
                Vector2 v8 = new Vector2(0, -oal + re1);
                Vector2 v16 = new Vector2(-dc2 / 2 - prfrad, v8.Y + Math.Sqrt((re1 + prfrad) * (re1 + prfrad) - (dc2 / 2 + prfrad) * (dc2 / 2 + prfrad)));
                Vector2 v7 = new Vector2((dc2 / 2 + prfrad) * re1 / (re1 + prfrad), (v16.Y - v8.Y) * re1 / (re1 + prfrad) + v8.Y);
                Vector2 v9 = new Vector2(-v7.X, v7.Y);
                Vector2 v6 = new Vector2(-v16.X - Math.Sqrt(prfrad * prfrad - (apmx - re1 - v16.Y + v8.Y) * (apmx - re1 - v16.Y + v8.Y)), -oal + apmx);
                Vector2 v10 = new Vector2(-v6.X, v6.Y);
                Vector2 v11 = new Vector2(-v5.X, v5.Y);
                Vector2 v12 = new Vector2(-v4.X, v4.Y);
                Vector2 v13 = new Vector2(-v3.X, v3.Y);
                Vector2 v14 = new Vector2(-v2.X, v2.Y);
                Vector2 v15 = new Vector2(-v1.X, v1.Y);
                Vector2 v17 = new Vector2(0, 2);
                Vector2 v18 = new Vector2(0, -oal - 2);
                //线段
                //主视图
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line6 = { v6, v10 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                LwPolyline Arc8 = new LwPolyline();
                Arc8.Vertexes.Add(new LwPolylineVertex(v6));
                Arc8.Vertexes.Add(new LwPolylineVertex(v7));
                Arc8.Vertexes[0].Bulge = Math.Tan((Math.Asin((v6.Y - v16.Y) / prfrad) + Math.Asin((v16.Y - v7.Y) / prfrad)) / 4);
                fun.PolyFill(dxf, Arc8, 0.5, contour);
                LwPolyline Arc9 = new LwPolyline();
                Arc9.Vertexes.Add(new LwPolylineVertex(v9));
                Arc9.Vertexes.Add(new LwPolylineVertex(v10));
                Arc9.Vertexes[0].Bulge = Math.Tan((Math.Asin((v6.Y - v16.Y) / prfrad) + Math.Asin((v16.Y - v7.Y) / prfrad)) / 4);
                fun.PolyFill(dxf, Arc9, 0.5, contour);
                LwPolyline Arc10 = new LwPolyline();
                Arc10.Vertexes.Add(new LwPolylineVertex(v9));
                Arc10.Vertexes.Add(new LwPolylineVertex(v7));
                Arc10.Vertexes[0].Bulge = (re1 + v7.Y - v8.Y) / v7.X;
                fun.PolyFill(dxf, Arc10, 0.5, contour);
                Vector2[] Line7 = { v14, v15 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line11 = { v11, v12 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v12, v13 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v13, v14 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v15, v1 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line17 = { v14, v2 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v13, v3 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v12, v4 };
                fun.drawBLine(dxf, Line19, 0.3, contour);
                Vector2[] Line21 = { v17, v18 };
                fun.drawPlinetype(dxf, Line21, 0.15, centre, Linetype.Center);
                Arc arc15 = new Arc(v8, re1, (pi / 2 - Math.Asin(v7.X / re1)) / pi * 180, (pi / 2 + Math.Asin(v7.X / re1)) / pi * 180);
                Arc arc16 = new Arc(v16, prfrad, -Math.Acos(v7.X / re1) / pi * 180, Math.Asin((v6.Y - v16.Y) / prfrad) / pi * 180);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(v6, new Vector2(0, -oal)), offset - v6.X / 2 + dc1 / 2, 270, dimensionStyle);
                dim1.UserText = "APMX = " + Math.Round(apmx / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(new Vector2(v16.X + prfrad, v16.Y), new Vector2(-v16.X - prfrad, v16.Y)), -offset - v16.Y - oal, 0, dimensionStyle);
                dim2.UserText = "DC_2 = " + Math.Round(dc2 / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v1, v3), offset + 0.25 + dc1 / 2 - v3.X, 270, dimensionStyle);
                dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v1, new Vector2(0, -oal)), offset * 2 - v1.X / 2 + dc1 / 2, 270, dimensionStyle);
                dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v14, v2), offset + 0.5, 0, dimensionStyle);
                dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                LinearDimension dim7 = new LinearDimension(new Line(v12, v4), -(v4.Y - v5.Y) / 2, 0, dimensionStyle);
                dim7.UserText = "DN = " + Math.Round(dn / scale, 2);
                dxf.AddEntity(dim7);
                //尺寸8
                RadialDimension dimrad8 = new RadialDimension(arc15, -100, re1 - offset, dimensionStyle);//DimensionStyle.Default);
                dimrad8.UserText = "RE = " + Math.Round(re1 / scale, 2);
                dxf.AddEntity(dimrad8);
                //尺寸9
                RadialDimension dimrad9 = new RadialDimension(arc16, 20, prfrad - offset, dimensionStyle);//DimensionStyle.Default);
                dimrad9.UserText = "PRFRAD = " + Math.Round(prfrad / scale, 2);
                dxf.AddEntity(dimrad9);
                //尺寸10
                LinearDimension dim10 = new LinearDimension(new Line(new Vector2(v8.X - re1, v8.Y), new Vector2(v8.X + re1, v8.Y)), -offset * 2 - v8.Y - oal, 0, dimensionStyle);
                dim10.UserText = "DC_1 = " + Math.Round(dc1 / scale, 2);
                dxf.AddEntity(dim10);
                //图框
                if (isframe == 1)
                {
                    Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }
            if (btc == "24")
            {
                double dc11 = dc2 - 2 * prfrad + 2 * Math.Sqrt(prfrad * prfrad - apmx * apmx / 4);
                double a = Math.Asin(apmx / 2 / prfrad);
                Vector2 v1 = new Vector2(dconms / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(v1.X + 0.5, -0.5);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(dn / 2, v3.Y - (dconms - dn) / 2 * Math.Cos(45 * pi / 180) / Math.Sin(45 * pi / 180));
                Vector2 v5 = new Vector2(v4.X, -oal + lh);
                Vector2 v6 = new Vector2(dc2 / 2, -oal + lh);
                Vector2 v7 = new Vector2(dc2 / 2, v6.Y - (lh - apmx * 3) / 4);
                Vector2 v8 = new Vector2(v6.X, v7.Y - apmx);
                Vector2 v9 = new Vector2(dc2 / 2, v8.Y - (lh - apmx * 3) / 4);
                Vector2 v10 = new Vector2(v9.X, v9.Y - apmx);
                Vector2 v11 = new Vector2(v10.X, v10.Y - (lh - apmx * 3) / 4);
                Vector2 v12 = new Vector2(v11.X, v11.Y - apmx);
                Vector2 v13 = new Vector2(v12.X, -oal);
                Vector2 v14 = new Vector2(-v13.X, v13.Y);
                Vector2 v15 = new Vector2(-v12.X, v12.Y);
                Vector2 v16 = new Vector2(-v11.X, v11.Y);
                Vector2 v17 = new Vector2(-v10.X, v10.Y);
                Vector2 v18 = new Vector2(-v9.X, v9.Y);
                Vector2 v19 = new Vector2(-v8.X, v8.Y);
                Vector2 v20 = new Vector2(-v7.X, v7.Y);
                Vector2 v21 = new Vector2(-v6.X, v6.Y);
                Vector2 v22 = new Vector2(-v5.X, v5.Y);
                Vector2 v23 = new Vector2(-v4.X, v4.Y);
                Vector2 v24 = new Vector2(-v3.X, v3.Y);
                Vector2 v25 = new Vector2(-v2.X, v2.Y);
                Vector2 v26 = new Vector2(-v1.X, v1.Y);
                Vector2 v27 = new Vector2(0, 2);
                Vector2 v28 = new Vector2(0, -oal - 2);
                Vector2 v29 = new Vector2(-dc11 / 2 - prfrad, (v17.Y + v18.Y) / 2);
                //线段
                //主视图
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v7 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v9, v8 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                LwPolyline Arc8 = new LwPolyline();
                Arc8.Vertexes.Add(new LwPolylineVertex(v7));
                Arc8.Vertexes.Add(new LwPolylineVertex(v8));
                Arc8.Vertexes[0].Bulge = Math.Tan(a / 2);
                fun.PolyFill(dxf, Arc8, 0.5, contour);
                Vector2[] Line9 = { v11, v10 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                LwPolyline Arc10 = new LwPolyline();
                Arc10.Vertexes.Add(new LwPolylineVertex(v9));
                Arc10.Vertexes.Add(new LwPolylineVertex(v10));
                Arc10.Vertexes[0].Bulge = Math.Tan(a / 2);
                fun.PolyFill(dxf, Arc10, 0.5, contour);
                Vector2[] Line11 = { v26, v25 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v12, v13 };
                fun.drawBLine(dxf, Line12, 0.5, contour);
                Vector2[] Line13 = { v13, v14 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v15, v14 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v25, v24 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v16, v17 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v24, v23 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v26, v1 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v27, v28 };
                fun.drawPlinetype(dxf, Line19, 0.15, centre, Linetype.Center);
                Vector2[] Line20 = { v25, v2 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v24, v3 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v23, v4 };
                fun.drawBLine(dxf, Line22, 0.3, contour);
                Vector2[] Line24 = { v21, v5 };
                fun.drawBLine(dxf, Line24, 0.3, contour);
                Vector2[] Line25 = { v19, v8 };
                fun.drawBLine(dxf, Line25, 0.3, contour);
                Vector2[] Line26 = { v23, v22 };
                fun.drawBLine(dxf, Line26, 0.3, contour);
                Vector2[] Line27 = { v21, v20 };
                fun.drawBLine(dxf, Line27, 0.3, contour);
                Vector2[] Line28 = { v19, v18 };
                fun.drawBLine(dxf, Line28, 0.3, contour);
                Vector2[] Line29 = { v20, v7 };
                fun.drawBLine(dxf, Line29, 0.3, contour);
                Vector2[] Line30 = { v18, v9 };
                fun.drawBLine(dxf, Line30, 0.3, contour);
                Vector2[] Line31 = { v17, v10 };
                fun.drawBLine(dxf, Line31, 0.3, contour);
                Vector2[] Line32 = { v16, v11 };
                fun.drawBLine(dxf, Line32, 0.3, contour);
                Vector2[] Line33 = { v15, v12 };
                fun.drawBLine(dxf, Line33, 0.3, contour);
                LwPolyline Arc34 = new LwPolyline();
                Arc34.Vertexes.Add(new LwPolylineVertex(v11));
                Arc34.Vertexes.Add(new LwPolylineVertex(v12));
                Arc34.Vertexes[0].Bulge = Math.Tan(a / 2);
                fun.PolyFill(dxf, Arc34, 0.5, contour);
                LwPolyline Arc35 = new LwPolyline();
                Arc35.Vertexes.Add(new LwPolylineVertex(v15));
                Arc35.Vertexes.Add(new LwPolylineVertex(v16));
                Arc35.Vertexes[0].Bulge = Math.Tan(a / 2);
                fun.PolyFill(dxf, Arc35, 0.5, contour);
                LwPolyline Arc36 = new LwPolyline();
                Arc36.Vertexes.Add(new LwPolylineVertex(v17));
                Arc36.Vertexes.Add(new LwPolylineVertex(v18));
                Arc36.Vertexes[0].Bulge = Math.Tan(a / 2);
                fun.PolyFill(dxf, Arc36, 0.5, contour);
                LwPolyline Arc37 = new LwPolyline();
                Arc37.Vertexes.Add(new LwPolylineVertex(v19));
                Arc37.Vertexes.Add(new LwPolylineVertex(v20));
                Arc37.Vertexes[0].Bulge = Math.Tan(a / 2);
                fun.PolyFill(dxf, Arc37, 0.5, contour);
                Arc arc8 = new Arc(v29, prfrad, a * 180 / pi, -a * 180 / pi);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                LinearDimension dim1 = new LinearDimension(new Line(new Vector2(-dc11 / 2, (v15.Y + v16.Y) / 2), new Vector2(dc11 / 2, (v15.Y + v16.Y) / 2)), -offset - v11.Y + v13.Y + apmx / 2, 0, dimensionStyle);
                dim1.UserText = "DC_1 = " + Math.Round(dc11 / scale, 2);
                dxf.AddEntity(dim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v14, v13), -offset * 2, 0, dimensionStyle);
                dim2.UserText = "DC_2 = " + Math.Round(dc2 / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v9, v10), offset, 270, dimensionStyle);
                dim3.UserText = "APMX = " + Math.Round(apmx / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v1, v3), offset + 0.25 + v9.X - v3.X, 270, dimensionStyle);
                dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v13, v1), offset * 3 + 0.25 + (v9.X - v3.X) / 2, 270, dimensionStyle);
                dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v25, v2), offset + 0.5, 0, dimensionStyle);
                dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                RadialDimension dimrad7 = new RadialDimension(arc8, 20, -offset, dimensionStyle);//DimensionStyle.Default);
                dimrad7.UserText = "PRFRAD = " + Math.Round(prfrad / scale, 2);
                dxf.AddEntity(dimrad7);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v23, v4), -(v4.Y - v6.Y) / 2, 0, dimensionStyle);
                dim8.UserText = "DN = " + Math.Round(dn / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v6, v13), offset * 2, 270, dimensionStyle);
                dim9.UserText = "LH = " + Math.Round(lh / scale, 2);
                dxf.AddEntity(dim9);
                //图框
                if (isframe == 1)
                {
                    Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 210 - oal / 2));
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }
            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
    }
}
